package com.ruoyi.project.myexperiment.mapper;

import com.ruoyi.project.myexperiment.domain.DetailsDto;
import com.ruoyi.project.myexperiment.domain.MyExment;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface MyExmentMapper {

    /**
     * 查询我的实验列表
     * @param myExment
     * @return
     */
    public List<MyExment> selectExmentList(MyExment myExment);

    @Select("select et.id as id,et.experiment_name as experimentName,et.user_id as createId,ifnull(et.experiment_type,0) as experimentType,et.begin_time as beginTime,et.end_time as endTime,cm.course_name as courseName,\n" +
            "     CONCAT(tl.lab_name,date_format(ld.order_time, '%Y-%m-%d'),'   (第',ld.classtime_id,'节)   ') as experimentMessage,et.experiment_introduce as introduce,et.experiment_shape as experimentShape,\n" +
            "\t\t\tex.path as path,ow.web_name as webName,ow.web_inter as webInter,dt.dict_label as experimentTypes,et.accessory_id as accessoryId,et.accessory_path as accessoryPath,et.allow as allow\n" +
            "     from experiment_teach et\n" +
            "      left join tb_kaike_plan tkp on tkp.id = et.course_id\n" +
            "      left join tb_total_course_main cm on cm.id=tkp.course_id\n" +
            "      left join lab_date ld on et.lab_date_id=ld.id\n" +
            "      left join  sys_user_ment s on s.user_id=et.id\n" +
            "      left join tb_lab tl on ld.lab_id=tl.id left join explorer ex on ex.id=et.accessory_id\n" +
            "      left join online_web ow on et.online_id=ow.id\n" +
            "      left join sys_dict_data dt on dt.dict_value=et.experiment_type\n" +
            " where et.id=#{id} and dt.dict_type='web_type'")
    DetailsDto seletExmentDetail(@Param("id") String id);


    /*se.experiment_results as experimentResult*/
    @Select("select et.id as id,et.experiment_name as experimentName,et.user_id as createId,ifnull(et.experiment_type,0) as experimentType,cm.course_name as courseName,\n" +
            "     CONCAT(tl.lab_name,date_format(ld.order_time, '%Y-%m-%d'),'   (第',ld.classtime_id,'节)   ') as experimentMessage,et.experiment_introduce as introduce,se.experiment_shape as experimentShape,\n" +
            "\t\t\tse.path as filePath,se.userId as userId,se.experiment_results as experimentResult,dt.dict_label as experimentTypes\n" +
            "     from experiment_teach et\n" +
            "      left join tb_kaike_plan tkp on tkp.id = et.course_id\n" +
            "      left join tb_total_course_main cm on cm.id=tkp.course_id\n" +
            "      left join lab_date ld on et.lab_date_id=ld.id\n" +
            "      left join  sys_user_ment s on s.user_id=et.id\n" +
            "      left join sys_dict_data dt on dt.dict_value=et.experiment_type\n" +
            "      left join tb_lab tl on ld.lab_id=tl.id left join student_experiment se on se.id=et.id where et.id=#{id} and se.userId=#{userId} and dt.dict_type='web_type' GROUP BY se.userId")
    DetailsDto seletExmentDetail2(HashMap<String,Long> map);


    /**
     * 取消发布
     * @param id
     * @return
     */
    public int quxiaoFabu(HashMap<String,Object> map);


    /*experiment_results   #{experimentResult}    添加实验结果*/
    @Insert("insert into student_experiment(id,experiment_name,course_name,type,experiment_message,userId," +
            "userName,experiment_shape,introduce,ceeate_id,experiment_results) values(#{id},#{experimentName},#{courseName},#{experimentTypes}," +
            "#{experimentMessage},#{userId},#{userName},#{experimentShape},#{introduce},#{createId},#{experimentResult})")
    boolean insertDetail(DetailsDto detailsDto);


    boolean updateDetail(DetailsDto detailsDto);

    @Select("select * from student_experiment")
    List<DetailsDto> seletExmentDetail1(int id);


    @Update("update student_experiment set score=#{score}," +
            "experiment_shape=#{experimentShape} where id=#{id} and userId=#{userId}")
    boolean insertDetailtwo(DetailsDto detailsDto);


    /**
     * 插入文件路径
     */
    @Update("update student_experiment set path=#{filePath} where id=#{id} and userId=#{userId}")
    boolean insertFileInfo(DetailsDto file);

   /* *//**
     * 插入文件路径  ，若果该学生没有提交该实验的话
     *//*
    @Insert("insert into student_experiment(path,id,userId) values(#{path},#{id},#{userId})")
    boolean insertDetailDao(DetailsDto detailsDto);

    *//**
     * 查询表中是否有此数据
     * @param detailsDto
     * @return
     *//*
    @Select("select * from student_experiment where id=#{id} and userId={#userId}")
    boolean getById(DetailsDto detailsDto);*/


    /**
     * 根據實驗所選擇的資源查詢對應的網址
     */
    List<String> getPathbyAccessoryId(String[] ids);

}
